package com.kkang.betmachine.ryc;

import com.kkang.betmachine.config.MatheType;
import com.kkang.betmachine.entity.LanQiuMatche;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yongk_liu
 **/
public class LanQiuRycMatcheUtil extends RycMatcheUitl {

    /**
     * 拉取如意彩比赛数据
     *
     * @return
     */
    @Override
    public List pullMatches(MatheType matheType) {
        List matches = LanQiuRycNetUti.pullMatch(matheType);
        return parserMatcheList(matheType, matches);
    }

    /**
     * 解析ryc比赛为自己match
     *
     * @param matheType
     * @param rycMatches
     * @return
     */
    private List parserMatcheList(MatheType matheType, List rycMatches) {
        if (rycMatches == null)
            return null;
        System.out.println("开始转换为Matche类型集合");
        List<LanQiuMatche> matches = new ArrayList<>();
        for (int i = 0; i < rycMatches.size(); i++) {
            LanQiuRycMatche o = (LanQiuRycMatche) rycMatches.get(i);
            LanQiuMatche matche = new LanQiuMatche();

            matche.setTeamId(o.getDay() + "|" + o.getWeekId()+ "|" + o.getTeamId());
            matche.setUnsport(StringUtils.isEmpty(o.getUnsupport()) ? "" : (o.getUnsupport().contains("_" + matheType.getJingcaiType()) ? o.getUnsupport() : ""));
            matche.setJ00005(new String[]{
                    StringUtils.isEmpty(o.getV0()) ? "" : "0",
                    StringUtils.isEmpty(o.getV3()) ? "" : "3"
            });
            matche.setJ00006(new String[]{
                    StringUtils.isEmpty(o.getLetVs_v0()) ? "" : "0",
                    StringUtils.isEmpty(o.getLetVs_v3()) ? "" : "3"
            });
            matche.setJ00007(new String[]{
                    StringUtils.isEmpty(o.getV01()) ? "" : "01",
                    StringUtils.isEmpty(o.getV02()) ? "" : "02",
                    StringUtils.isEmpty(o.getV03()) ? "" : "03",
                    StringUtils.isEmpty(o.getV04()) ? "" : "04",
                    StringUtils.isEmpty(o.getV05()) ? "" : "05",
                    StringUtils.isEmpty(o.getV06()) ? "" : "06",
                    StringUtils.isEmpty(o.getV11()) ? "" : "11",
                    StringUtils.isEmpty(o.getV12()) ? "" : "12",
                    StringUtils.isEmpty(o.getV13()) ? "" : "13",
                    StringUtils.isEmpty(o.getV14()) ? "" : "14",
                    StringUtils.isEmpty(o.getV15()) ? "" : "15",
                    StringUtils.isEmpty(o.getV16()) ? "" : "16"
            });
            matche.setJ00008(new String[]{
                    StringUtils.isEmpty(o.getL()) ? "" : "2",
                    StringUtils.isEmpty(o.getG()) ? "" : "1"
            });

            matches.add(matche);
        }
        System.out.println("结束转换为Matche类型集合");
        return matches;
    }
}
